#include <stdexcept> 
#include <Unit.h>
#include <iostream>
#include <sstream>
Unit::Unit(int unit,CompareSystermType type):unit(unit),type(type)
{
}
int Unit::getBaseVlaue(int amount) const
{
    return amount * unit;
}
int Unit::getAmount(int baseVlaue) const
{
    return baseVlaue / unit;
}
CompareSystermType Unit::getType() const
{
	return type;
}
bool Container::operator==(const Container& container) const
{
	if(this->unit.getType() != container.unit.getType())
	{
		throw std::invalid_argument("Different SystermType COMPARE");
	}	
    else
	{
		return this->unit.getBaseVlaue(this->amount) == container.unit.getBaseVlaue(container.amount);
	}
}

bool Container::operator!=(const Container& container) const
{
	if(this->unit.getType() != container.unit.getType())
	{
		throw std::invalid_argument("Different SystermType COMPARE");
	}	
    else
	{
		return !(*this == container);
	}
    
}
Container  Container::operator+(const Container& container) 
{ 
    int amount = 0;

	if(this->unit.getType() != container.unit.getType())
	{
			throw std::invalid_argument("Different SystermType ADD");
	}

    amount = this->unit.getAmount(this->unit.getBaseVlaue(this->amount) 
					+ container.unit.getBaseVlaue(container.amount));

    return {amount, this->unit};
}
Container::Container(int amount, const Unit& unit) : amount(amount), unit(unit)
{
}

const std::string Container::printUnitStepString()
{
    return this->unit.showUnitStepString(this->amount);
}
const std::string Container::printBaseUnitString()
{
    return this->unit.showBaseUnitString(this->amount);
}
